﻿

class TorusGetCell implements IGetCell {
    grid: IGrid;
    deadCell: DefaultCell;
    Init(grid: IGrid) {
        this.grid = grid;
        
    }


    Execute(x: number, y: number) {
        if (y < 0)
            y = this.grid.Height - 1;
        if (y >= this.grid.Height)
            y = 0;

        if (x < 0)
            x = this.grid.Width - 1;
        if (x >= this.grid.Width)
            x = 0;


        return this.grid.GetCellRaw(x, y);


    }


} 